var app = angular.module('myApp', []);
app.controller('trpList', function($scope,$http) {
    var initData = [
        {
            index:0,
            item: '病害管理',
            list: [
                {
                    imgUrl:'images/trp/bh-1.png',
                    name: '三保奥思-1%蛇床子素微乳剂',
                    rules: '农药登记证号：LS20160045',
                    link:'trp/detailA001'
                },{
                    imgUrl:'images/trp/bh-2.png',
                    name: '2%氨基寡糖素水剂',
                    rules: '农药登记证号：PD20151926',
                    link:'trp/detailA002'
                },{
                    imgUrl:'images/trp/bh-3.png',
                    name: '诺荷 Nuohe-丁子·香芹酚',
                    rules: '农药登记证号：PD20110170',
                    link:'trp/detailA003'
                },{
                    imgUrl:'images/trp/bh-4.png',
                    name: '雅尊-枯草芽孢杆菌水乳剂',
                    rules: '农药登记证号：PD20151486',
                    link:'trp/detailA004'
                },{
                    imgUrl:'images/trp/bh-5.png',
                    name: '特锐菌 Trianum-哈茨木霉菌',
                    rules: '农药登记证号：微生物肥（2013）准字（1084）号',
                    link:'trp/detailA005'
                }
            ]
        },{
            index:1,
            item: '虫害管理',
            list: [
                {
                    imgUrl:'images/trp/ch-1.png',
                    name: '三保奇花-1.5%除虫菊素水乳剂',
                    rules: '农药登记证号：PD20098425',
                    link:'trp/detailB001'
                },{
                    imgUrl:'images/trp/ch-2.png',
                    name: '碧拓10-0.5%苦参碱可溶液剂',
                    rules: '农药登记证号：PD20132711',
                    link:'trp/detailB002'
                },{
                    imgUrl:'images/trp/ch-3.png',
                    name: '三保罗藤-5%鱼藤酮可溶液剂',
                    rules: '农药登记证号：PD20150623',
                    link:'trp/detailB003'
                },{
                    imgUrl:'images/trp/ch-4.png',
                    name: '碧拓-0.5%苦参碱可溶液剂',
                    rules: '农药登记证号：PD20132711',
                    link:'trp/detailB004'
                },{
                    imgUrl:'images/trp/ch-5.png',
                    name: '烟欢-苏云金杆菌(BT)',
                    rules: '农药登记证号：PD20100788',
                    link:'trp/detailB005'
                },{
                    imgUrl:'images/trp/ch-6.png',
                    name: '清源保-1.5%除虫菊水乳剂',
                    rules: '农药登记证号：PD20121952',
                    link:'trp/detailB006'
                }
            ]
        },{
            index:2,
            item: '辅助剂',
            list: [
                {
                    imgUrl:'images/trp/fzj-1.png',
                    name: '百特普Z116-石蜡油',
                    rules: '',
                    link:'trp/detailC001'
                },{
                    imgUrl:'images/trp/fzj-2.png',
                    name: '聚多喜',
                    rules: '',
                    link:'trp/detailC002'
                },{
                    imgUrl:'images/trp/fzj-3.png',
                    name: '倍加喜',
                    rules: '',
                    link:'trp/detailC003'
                },{
                    imgUrl:'images/trp/fzj-4.png',
                    name: '三保奥宁-70%天然植物油',
                    rules: '',
                    link:'trp/detailC004'
                }
            ]
        }, {
            index:3,
            item: '生物授粉及物理防控',
            list: [
                {
                    imgUrl:'images/trp/fk-1.png',
                    name: '昆虫性诱剂',
                    rules: '',
                    link:'trp/detailD001'
                },{
                    imgUrl:'images/trp/fk-2.png',
                    name: '诱虫板',
                    rules: '',
                    link:'trp/detailD002'
                },{
                    imgUrl:'images/trp/fk-3.png',
                    name: '科伯特熊蜂',
                    rules: '',
                    link:'trp/detailD003'
                }
            ]
        },{
            index:4,
            item: '植物生长调节及土壤改善',
            list: [
                {
                    imgUrl:'images/trp/tr-1.png',
                    name: '培元 ProFunda',
                    rules: '',
                    link:'trp/detailE001'
                },{
                    imgUrl:'images/trp/tr-2.png',
                    name: '培基 ProParva',
                    rules: '',
                    link:'trp/detailE002'
                },{
                    imgUrl:'images/trp/tr-3.png',
                    name: '培经 ProFortum',
                    rules: '',
                    link:'trp/detailE003'
                },{
                    imgUrl:'images/trp/tr-4.png',
                    name: '培盛 ProTerrum',
                    rules: '',
                    link:'trp/detailE004'
                }
            ]
        },
    ]
    $scope.dataList = initData;

    $scope.selectedIndex = 0;

    $scope.currentData = function (i) {
        var dataList = [];
        $scope.selectedIndex = i;
        if($scope.selectedIndex == 0){
            $scope.dataList = initData;
        }else{
            dataList.push(initData[$scope.selectedIndex-1]);
            $scope.dataList = dataList;
        }
    }
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var id = GetQueryString('id');
    $scope.currentData(id);
});